<template>
	<view class="index">



		<view class="banner">
			<u-swiper height="340" 
					  imgMode="aspectFill" :list="bannerList" 
					  keyName="icon" indicator indicatorMode="line"
					  circular @click="clickSwiper"></u-swiper>
		</view>
		
		
 			<view class="index_nav">
 			  <view @click="order_milk"   class="order_button">订奶专区</view>
 			  <view @click="student_info" class="child_button">学生信息</view>
 			</view>
   
     
	</view>
</template>

<script>
	import * as UserApi from '@/api/user.js'
	import * as IndexApi from '@/api/index.js'
	import {
		baseUrl
	} from '@/utils/config.js'
	export default {
	 
		data() {
			return {
				//officialShow: false,
				page: 1,
				bannerList: [],
				isLogin : false,
			}
		},
		created() {

		},
		
		onLoad() {
			this.getBannerList()
		},
		 onShow() {
			if (uni.getStorageSync('user_id')) {
				this.isLogin = true
		 
				console.log("登陆了")
		 
			}
			else if (!this.isLogin) {
				/* uni.navigateTo({
					url: "/pages/login/index"
				}) */
				console.log("还没登陆")
			} 
		  
		 },

		/*分享当前页面*/
		// onShareAppMessage() {},
		// onShareTimeline() {},

		methods: {


order_milk() {
  console.log("用户点击了立刻订奶");
  uni.switchTab({
    url: '/pages/activity/activity',
    success: () => {
      console.log("跳转成功");
    },
    fail: (err) => {
      console.error("跳转失败", err);
    }
  });
},
 


// order_milk() {
//       // 执行订奶操作
//       console.log("用户点击了立刻订奶");
//       uni.navigateTo({
//         url: '/pages/activity/activity'
//       });
//     },
	
	
    student_info() {
      // 执行登记操作
      console.log("用户点击了立刻登记");
	  uni.navigateTo({
	  	url: '/pages/user/student_list'
	  })
    },

	
 
			getBannerList() 
			{
				let that = this;
				IndexApi.bannerList().then(res => {
					res.info.forEach(e => {
						e.icon = baseUrl + '/uploadfiles/event/' + e.icon
					})
					this.bannerList = res.info
					console.log(this.bannerList)
				})
			},

			clickSwiper(index) {
				if (this.bannerList[index].link) {
					uni.navigateTo({
						url: this.bannerList[index].link
					});
				}

			},

 
		},
	}
</script>

<style scoped lang="scss">
	.index {height: 100vh; background-color:#22428d;}
	.banner {}
	.index_nav{background-color: #c9ddf8;margin: 25rpx;
	border-radius: 7px;height: 155px;padding:32rpx 26rpx;display: flex;}
	.order_button{height: 255rpx;width: 255rpx; float: left;background-color: #ffffff;margin: 0 35rpx;
    text-align: center;line-height: 429rpx;border-radius: 7px;  background-image: url("/static/imgs/milk-btn.png");
	background-repeat: no-repeat;background-position: center; }
	.child_button{height: 255rpx;width: 255rpx;float: left;background-color: #ffffff;margin: 0 35rpx;
    text-align: center;line-height: 429rpx;border-radius: 7px; background-image: url("/static/imgs/student-btn.png");
	background-repeat: no-repeat;background-position: center;}
	
</style>